package com.xuebang.admin.web;


public class Result<T> {

    private String state;/*1:error;2:success*/
    private T result;

    private Result(String state, T result) {
        this.state = state;
        this.result = result;
    }

    public T getResult() {
        return result;
    }

    public String getState() {
        return state;
    }

    public static <X> Result<X> error(X x) {
        return new Result<X>("0", x);
    }

    public static <X> Result<X> success(X x) {
        return new Result<X>("1", x);
    }

    public static void main(String[] args) {
        Result<String> stringResult = Result.error("abcd");
        System.out.println(stringResult.getResult());

        Result<Long> longResult = Result.success(100l);
        System.out.println(longResult.getResult());
    }

}
